package global

import (
	"runtime"
	"strings"
)

type ENV int

const (
	DEV ENV = iota
	TEST
	UAT
	PROD
)

var DEFAULT_ENV ENV = TEST

type CHAIN string

const (
	ETH CHAIN = "ETH"
	BNB CHAIN = "BNB"
	TRC CHAIN = "TRC"
)

type Currency string

const (
	USDTERC20 Currency = "USDT_ERC20"
	USDTBEP20 Currency = "USDT_BEP20"
	USDTTRC20 Currency = "USDT_TRC20"

	BCPCBEP20 Currency = "BCPC_BEP20"
	BCPCTRC20 Currency = "BCPC_TRC20"
)

var ethPermit2Contract = strings.ToLower("")
var bnbPermit2Contract = strings.ToLower("0x31c2F6fcFf4F8759b3Bd5Bf0e1084A055615c768")

var macLogFile = "/Users/raymond/totem/temp/logs/relay.log"
var winLogFile = "D:/temp/logs/relay.log"
var linuxLogFile = "/home/ec2-user/logs/relay.log"

var macTempLogFile = "/Users/raymond/totem/temp/logs/tmp_relay.log"
var winTempLogFile = "D:/temp/logs/tmp_relay.log"
var linuxTempLogFile = "/home/ec2-user/logs/tmp_relay.log"

func GetAppAddr() string {
	port := "9800"
	switch DEFAULT_ENV {
	case DEV:
		return "http://127.0.0.1:" + port
	case TEST:
		return "http://127.0.0.1:" + port
	case UAT:
		return "http://127.0.0.1:" + port
	case PROD:
		return "http://127.0.0.1:" + port
	}
	return "http://127.0.0.1:" + port
}

func GetLogfilepath() string {
	switch runtime.GOOS {
	case "windows":
		return winLogFile
	case "darwin":
		return macLogFile
	case "linux":
		return linuxLogFile
	}
	return linuxLogFile
}

func GetTempLogfilepath() string {
	switch runtime.GOOS {
	case "windows":
		return winTempLogFile
	case "darwin":
		return macTempLogFile
	case "linux":
		return linuxTempLogFile
	}
	return linuxTempLogFile
}

func GetPermit2Contract(chain CHAIN) string {
	switch chain {
	case ETH:
		return ethPermit2Contract
	case BNB:
		return bnbPermit2Contract
	}
	return bnbPermit2Contract
}
